/**
 * Copyright 2010 Creative Works, Inc.
 * Creative Works licenses this file to you under the Apache License, version
 * 2.0 (the "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *    http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.  See the License for the specific language governing
 * permissions and limitations under the License.
 */

package org.sendvox.freswitch.core;

/**
 * All commands that can be sent to FreeSwitch socket.
 */
public enum Command {

	/**
	 * Send an API command to the FreeSWITCH server. This method blocks further
	 * execution until the command has been executed.
	 * <p>
	 * <code>api($command[, $arguments])</code>
	 * </p>
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#api
	 * </p>
	 */
	API("api"),

	/**
	 * Send an api command (non-blocking mode) this will let you execute a job
	 * in the background and the result will be sent as an event with an
	 * indicated uuid to match the reply to the command)
	 * <p>
	 * <code>bgapi($command[, $arguments][,$custom_job_uuid])</code>
	 * </p>
	 * http://wiki.freeswitch.org/wiki/Event_Socket#bgapi
	 */
	BGAPI("bgapi"),
	/**
	 * Close the socket connection
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#exit
	 * </p>
	 */
	EXIT("exit"),

	/**
	 * Socket resume for Outbound connection only. If enabled, the dialplan will
	 * resume execution with the next action after the call to the socket
	 * application. If there is a bridge active when the disconnect happens, it
	 * is killed.
	 */

	RESUME("resume"),

	/**
	 * Enable or disable events by class or all (plain or xml or json output
	 * format)
	 * <p>
	 * <code>event plain <list of events to log or all for all></code>
	 * </p>
	 * The event command are used to subscribe on events from FreeSWITCH. You
	 * may specify any number events on the same line, they should be separated
	 * with space.
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#event
	 * </p>
	 */
	EVENT_PLAIN("event plain"),

	/**
	 * Enable or disable events by class or all (plain or xml or json output
	 * format)
	 * <p>
	 * <code>event plain <list of events to log or all for all></code>
	 * </p>
	 * The event command are used to subscribe on events from FreeSWITCH. You
	 * may specify any number events on the same line, they should be separated
	 * with space.
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#event
	 * </p>
	 */
	EVENT_JSON("event json"),

	/**
	 * Enable or disable events by class or all (plain or xml or json output
	 * format)
	 * <p>
	 * <code>event plain <list of events to log or all for all></code>
	 * </p>
	 * The event command are used to subscribe on events from FreeSWITCH. You
	 * may specify any number events on the same line, they should be separated
	 * with space.
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#event
	 * </p>
	 */

	EVENT("event"),

	/**
	 * Get a variable from a channel.
	 * <p>
	 * <code> uuid_getvar <uuid> <varname> </code>
	 * </p>
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Mod_commands#uuid_getvar
	 * </p>
	 */
	UUID_GETVAR("uuid_getvar"),

	/**
	 * Set a variable on a channel. If value is omitted, the variable is unset.
	 * <p>
	 * <code>uuid_setvar <uuid> <varname> [value] </code>
	 * </p>
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Mod_commands#uuid_setvar
	 * </p>
	 */
	UUID_SETVAR("uuid_setvar"),

	/**
	 * Specify event types to listen for. Note, this is not a filter out but
	 * rather a "filter in," that is, when a filter is applied only the filtered
	 * values are received. Multiple filters on a socket connection are allowed.
	 * <p>
	 * <code>filter <EventHeader> <ValueToFilter></code>
	 * </p>
	 * <p>
	 * Example: filter Event-Name CHANNEL_EXECUTE filter Unique-ID
	 * d29a070f-40ff-43d8-8b9d-d369b2389dfe
	 * </p>
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#filter
	 * </p>
	 */
	FILTER("filter"),

	/**
	 * Specify the events which you want to revoke the filter. filter delete can
	 * be used when some filters are applied wrongly or when there is no use of
	 * the filter.
	 * <p>
	 * <code> filter delete <EventHeader> <ValueToFilter> </code>
	 * </p>
	 * <p>
	 * Example: filter delete Event-Name HEARTBEAT
	 * </p>
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#filter_delete
	 * </p>
	 */

	FILTER_DELETE("filter delete"),

	/**
	 * The divert_events switch is available to allow events that an embedded
	 * script would expect to get in the inputcallback to be diverted to the
	 * event socket.
	 * <p>
	 * Examples: <code>divert_events on</code> <code>divert_events off</code>
	 * </p>
	 * An inputcallback can be registered in an embedded script using
	 * setInputCallback(). Setting divert_events to "on" can be used for chat
	 * messages like gtalk channel, ASR events and others.
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#divert_events
	 * </p>
	 */
	DIVERT_EVENTS("divert_events"),

	/**
	 * Send an event into the event system (multi line input for headers)
	 * <p>
	 * <code>sendevent <event-name> </code>
	 * </p>
	 * <p>
	 * Example:
	 * <code>CUSTOM\nEvent-Name: CUSTOM\nEvent-Subclass: myevent::test\n</code>
	 * </>
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#sendevent
	 * </p>
	 * 
	 * @return
	 */
	SENDEVENT("sendevent"),

	/**
	 * Authentication
	 * <p>
	 * Reference: http://wiki.freeswitch.org/wiki/Event_Socket#auth
	 * </p>
	 */
	AUTH("auth"),

	/**
	 * The 'myevents' subscription allows your inbound socket connection to
	 * behave like an outbound socket connect. It will "lock on" to the events
	 * for a particular uuid and will ignore all other events, closing the
	 * socket when the channel goes away or closing the channel when the socket
	 * disconnects and all applications have finished executing.
	 * <p>
	 * Usage: <code>myevents <uuid></code>
	 * </p>
	 * Once the socket connection has locked on to the events for this
	 * particular uuid it will NEVER see any events that are not related to the
	 * channel, even if subsequent event commands are sent. If you need to
	 * monitor a specific channel/uuid and you need watch for other events as
	 * well then it is best to use a filter. You can also set the event format
	 * (plain, xml or json): Usage: <code>myevents plain <uuid> </code>
	 * <code>myevents json <uuid> </code> <code>myevents xml <uuid> </code> The
	 * default format is plain.
	 * <p>
	 * Reference: For Inbound connection:
	 * http://wiki.freeswitch.org/wiki/Event_Socket
	 * #Special_Case_-_.27myevents.27 For Outbound connection:
	 * http://wiki.freeswitch.org/wiki/Event_Socket_Outbound#Events
	 * </p>
	 */
	MYEVENTS_JSON("myevents json"),

	MYEVENTS("myevents"),

	/**
	 * The linger socket command was added to tell FS to wait for the last
	 * channel event before ending the connection Can only be used with Outbound
	 * connection.
	 */
	LINGER("linger"),

	/**
	 * Send all Events to Subscriber raised by some Event. For Inbound
	 * connection, uuid argument is mandatory.
	 * <p>
	 * Reference:
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_verbose_events
	 * </p>
	 */

	VERBOSE_EVENTS("verbose_events"),

	/**
	 * This causes an 180 Ringing to be sent to the originator. For Inbound
	 * connection, uuid argument is mandatory.
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_ring_ready
	 */

	RING_READY("ring_ready"),

	/**
	 * Records an entire phone call or session. For Inbound connection, uuid
	 * argument is mandatory.
	 * 
	 * Possible File Formats Simply set the file extension to define the
	 * recorded file's format. Use the console command show file to determine
	 * possible formats. record_session /tmp/test.gsm will produce a GSM encoded
	 * voice file which is raw data and is not in any container (e.g. wav, ogg,
	 * etc.). The sampling rate can not be influenced by the filename.
	 * record_session /tmp/test.mp3 will produce an MP3 file if mod_shout is
	 * loaded. You can use an external application to resample and manipulate
	 * the recorded file like sox or lame. Reference:
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_record_session
	 */

	RECORD_SESSION("record_session"),

	/**
	 * Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_bind_meta_app For
	 * Inbound connection, uuid argument is mandatory.
	 */
	BIND_META_APP("bind_meta_app"),

	/**
	 * Please refer to http://wiki.freeswitch.org/wiki/Misc.
	 * _Dialplan_Tools_bind_digit_action bind_digit_action(
	 * "test1,456,exec:playback,ivr/ivr-welcome_to_freeswitch.wav") For Inbound
	 * connection, uuid argument is mandatory.
	 */

	BIND_DIGIT_ACTION("bind_digit_action"),

	/**
	 * Please refer to http://wiki.freeswitch.org/wiki/Misc.
	 * _Dialplan_Tools_digit_action_set_realm >>>
	 * digit_action_set_realm("test1")
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	DIGIT_ACTION_SET_REALM("digit_action_set_realm"),

	/**
	 * >>> clear_digit_action("test1") For Inbound connection, uuid argument is
	 * mandatory.
	 */

	CLEAR_DIGIT_ACTION("clear_digit_action"),

	/**
	 * """Please refer to http://wiki.freeswitch.org/wiki/Misc.
	 * _Dialplan_Tools_wait_for_silence >>> wait_for_silence("200 15 10 5000")
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	WAIT_FOR_SILENCE("wait_for_silence"),

	/**
	 * """Please refer to http://wiki.freeswitch.org/wiki/Mod_vmd >>>
	 * vmd("start") >>> vmd("stop")
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	VMD("vmd"),

	/**
	 * """Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_start_dtmf >>>
	 * start_dtmf()
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	START_DTMF("start_dtmf"),

	/**
	 * """Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_stop_dtmf >>>
	 * stop_dtmf()
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	STOP_DTMF("stop_dtmf"),

	/**
	 * Please refer to http://wiki.freeswitch.org/wiki/Misc.
	 * _Dialplan_Tools_start_dtmf_generate >>> start_dtmf_generate()
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	START_DTMF_GENERATE("start_dtmf_generate"),

	/**
	 * Please refer to http://wiki.freeswitch.org/wiki/Misc.
	 * _Dialplan_Tools_stop_dtmf_generate >>> stop_dtmf_generate()
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	STOP_DTMF_GENERATE("stop_dtmf_generate"),

	/**
	 * Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_queue_dtmf Enqueue
	 * each received dtmf, that'll be sent once the call is bridged. >>>
	 * queue_dtmf("0123456789")
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	QUEUE_DTMF("queue_dtmf"),

	/**
	 * Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_flush_dtmf >>>
	 * flush_dtmf()
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	FLUSH_DTMF("flush_dtmf"),

	/**
	 * Please refer to http://wiki.freeswitch.org/wiki/Mod_fsv >>>
	 * play_fsv("/tmp/video.fsv")
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	PLAY_FSV("play_fsv"),

	/**
	 * Please refer to http://wiki.freeswitch.org/wiki/Mod_fsv >>>
	 * record_fsv("/tmp/video.fsv") For Inbound connection, uuid argument is
	 * mandatory.
	 */

	RECORD_FSV("record_fsv"),

	/**
	 * Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_transfer >>>
	 * transfer("3222 XML default") For Inbound connection, uuid argument is
	 * mandatory.
	 */

	TRANSFER("transfer"),

	/**
	 * Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_att_xfer >>>
	 * att_xfer("user/1001")
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	ATT_XFER("att_xfer"),

	/**
	 * Please refer to http://wiki.freeswitch.org/wiki/Misc.
	 * _Dialplan_Tools_endless_playback >>> endless_playback("/tmp/dump.gsm")
	 * For Inbound connection, uuid argument is mandatory.
	 */

	ENDLESS_PLAYBACK("endless_playback"),

	/**
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_record
	 */

	RECORD("record"),

	/**
	 * Please refer to http://wiki.freeswitch.org/wiki/Mod_conference >>>
	 * conference(args)
	 * 
	 * For Inbound connection, uuid argument is mandatory.
	 */

	CONFERENCE("conference"),

	/**
	 * "Please refer to http://wiki.freeswitch.org/wiki/Mod_commands#hupall"
	 */
	HUPALL("hupall"),

	/**
	 * """Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_sched_hangup >>>
	 * sched_hangup("+60 ALLOTTED_TIMEOUT") For Inbound connection, uuid
	 * argument is mandatory.
	 */

	SCHED_HANGUP("sched_hangup"),

	/**
	 * Please refer to
	 * http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_sched_transfer >>>
	 * sched_transfer("+60 9999 XML default") For Inbound connection, uuid
	 * argument is mandatory.
	 */

	SCHED_TRANSFER("sched_transfer"),

	/**
	 * Originate a new call.
	 * <p>
	 * <code> originate &lt;call_url&gt; &lt;exten&gt;|&&lt;application_name&gt;(&lt;app_args&gt;) [&lt;dialplan&gt;]
	 * [&lt;context&gt;][&lt;cid_name&gt;] [&lt;cid_num&gt;] [&lt;timeout_sec&gt;] </code>
	 * </p>
	 * <p>
	 * Parameters: <br/>
	 * <ul>
	 * <li><code>&lt;call_url&gt;</code> URL you are calling. For more info on
	 * sofia SIP URL syntax see: <a
	 * href="http://wiki.freeswitch.org/wiki/Sofia">FreeSwitch Endpoint
	 * Sofia</a> </li
	 * <li> <code>&lt;exten&gt;</code> Extension you are calling from
	 * <code>&lt;application_name&gt;</code> "&" plus an application name and
	 * args.<br/>
	 * Here is a list of valid application names that can be used here:
	 * <code>park</code>,<code>bridge</code>, <code>javascript/lua/perl</code>,
	 * <code>playback</code> (remove mod_native_file), and many others. <br/>
	 * <b>Note</b>: Use single quotes to pass arguments with spaces, e.g.
	 * <code>'&lua(test.lua arg1 arg2)'</code></li>
	 * <li><code>&lt;cid_name&gt;</code> CallerID name.</li>
	 * <li><code>&lt;cid_num&gt;</code> CallerID number.</li>
	 * <li><code>&lt;timeout_sec&gt;</code> Timeout in seconds.</li>
	 * </ul>
	 * <p>
	 * Reference: <a
	 * href="http://wiki.freeswitch.org/wiki/Mod_commands#originate"
	 * >http://wiki.freeswitch.org/wiki/Mod_commands#originate</a>
	 * </p>
	 */
	ORIGINATE("originate");

	private String literal;

	private Command(String commandName) {
		this.literal = commandName;
	}

	public String getName() {
		return literal;
	}

}
